import operate from '@dfeidao/atom-nodejs/db/operate';
// import sys_date from '@dfeidao/atom-nodejs/msg/sys-date';

interface Message {
	_id: string;
	usercode: string;
	user_name: string;
	name_spell: string;
	is_disabled: boolean;
	email: string;
	phone: string;
	avatar_path: string;
	avatar_name: string;
	avatar_type: string;
	productid: string;
}

export default async function atom(msg: Message, action_id: string, session_id: string, spaceid: string) {
	const systemid = '12';
	const { exec, update } = operate(action_id, session_id, systemid);

	update('pub_user', { _id: msg._id }, { _id: msg._id, usercode: msg.usercode, user_name: msg.user_name, name_spell: msg.name_spell, is_disabled: msg.is_disabled, email: msg.email, phone: msg.phone, avatar_path: msg.avatar_path, avatar_name: msg.avatar_name, avatar_type: msg.avatar_type });


	const res = await exec();
	if (res.code === 1) {
		return 'success';
	} else {
		return 'fail';
	}
}
